package com.qingcheng.controller.seckill;

import com.alibaba.dubbo.config.annotation.Reference;
import com.qingcheng.entity.PageResult;
import com.qingcheng.entity.Result;
import com.qingcheng.pojo.seckill.SeckillOrder;
import com.qingcheng.service.seckill.SeckillOrderService;
import org.springframework.web.bind.annotation.*;

import java.util.*;

@RestController
@RequestMapping("/seckillOrder")
public class SeckillOrderController {

    @Reference
    private SeckillOrderService seckillOrderService;

    @GetMapping("/findAll")
    public List<SeckillOrder> findAll(){
        return seckillOrderService.findAll();
    }

    @GetMapping("/findPage")
    public PageResult<SeckillOrder> findPage(int page, int size){
        return seckillOrderService.findPage(page, size);
    }

    @PostMapping("/findList")
    public List<SeckillOrder> findList(@RequestBody Map<String,Object> searchMap){
        return seckillOrderService.findList(searchMap);
    }

    @PostMapping("/findPage")
    public PageResult<SeckillOrder> findPage(@RequestBody Map<String,Object> searchMap,int page, int size){
        return  seckillOrderService.findPage(searchMap,page,size);
    }

    @GetMapping("/findById")
    public SeckillOrder findById(Long id){
        return seckillOrderService.findById(id);
    }


    @PostMapping("/add")
    public Result add(@RequestBody SeckillOrder seckillOrder){
        seckillOrderService.add(seckillOrder);
        return new Result();
    }

    @PostMapping("/update")
    public Result update(@RequestBody SeckillOrder seckillOrder){
        seckillOrderService.update(seckillOrder);
        return new Result();
    }

    @GetMapping("/delete")
    public Result delete(Long id){
        seckillOrderService.delete(id);
        return new Result();
    }

}
